const mongoose = require('mongoose');
const {Schema, model} = mongoose;

const MtmSchema = new Schema({
        matchId: {type: String},
        teamId: {type: String},
        /**area:   { type: String },
        format: { type: String },
        type:   { type: String },
        category: { type: String },
        gender: { type: String },
        divisionLevel: { type: Number },*/
    },{
        toJSON: {
            transform: function(doc, ret, options) {
                delete ret._id;
                delete ret.__v;
                return ret;
            }
        }
    });

MtmSchema.static('findById', function(id) { return this.find({matchId:id}); });
MtmSchema.static('removeById', function(id) { return this.remove({id}); });
MtmSchema.static('upsert', function(id, MtmData) {
    return this.findOneAndUpdate({id}, MtmData, { new:true, upsert: true })
});

module.exports = model('matchteams', MtmSchema);